package com.sc.nft.dto;

import com.sc.nft.entity.UserEcologyHatchRecords;
import com.sc.nft.enums.EcologyPoolLinkTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class NationalTreasuryDTO {
    @ApiModelProperty("daoId")
    private Long daoId;
    @ApiModelProperty("用户id")
    private Long userId;
    @ApiModelProperty("藏品id")
    private Long collectionId;
    @ApiModelProperty("数量")
    private BigDecimal linkCount;
    @ApiModelProperty("类型")
    private EcologyPoolLinkTypeEnum linkType;
    @ApiModelProperty("天数")
    private Integer linkDay;
    @ApiModelProperty("开始时间")
    private Date startTime;
    @ApiModelProperty("唯一标识")
    private String pkCode;

    public static NationalTreasuryDTO build(UserEcologyHatchRecords userEcologyHatchRecords,BigDecimal coefficient){
        NationalTreasuryDTO nationalTreasuryDTO = new NationalTreasuryDTO();
        nationalTreasuryDTO.setCollectionId(userEcologyHatchRecords.getCollectionId());
        nationalTreasuryDTO.setDaoId(userEcologyHatchRecords.getDaoId());
        nationalTreasuryDTO.setUserId(userEcologyHatchRecords.getUserId());
        nationalTreasuryDTO.setLinkCount(userEcologyHatchRecords.getEcologyPoints().multiply(coefficient.movePointLeft(2)).setScale(2, BigDecimal.ROUND_DOWN));
        nationalTreasuryDTO.setLinkType(EcologyPoolLinkTypeEnum.POINTS);
        nationalTreasuryDTO.setLinkDay(userEcologyHatchRecords.getHatchCycle());
        nationalTreasuryDTO.setStartTime(userEcologyHatchRecords.getCreateTime());
        nationalTreasuryDTO.setPkCode(userEcologyHatchRecords.getId().toString());
        return nationalTreasuryDTO;
    }


}
